package com.ming.interceptor;

import org.springframework.stereotype.Component;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Component
public class InterceptorConfig implements WebMvcConfigurer {
    @Override
    public void addInterceptors(InterceptorRegistry registry) {

        // 声明拦截器对象
        HandlerInterceptor interceptor = new SessionCheck();
        registry.addInterceptor(interceptor)
                .addPathPatterns("/**")
                .excludePathPatterns("/UserController/getUserByIdByPass")
                .excludePathPatterns("/UserController/saveUser")
                .excludePathPatterns("/UserController/logOut")
                .excludePathPatterns("/BusinessController/listBusinessByOrderTypeId")
                .excludePathPatterns("/BusinessController/getBusinessById")
                .excludePathPatterns("/CartController/listCart")
                .excludePathPatterns("/FoodController/listFoodByBusinessId")
        ;

        WebMvcConfigurer.super.addInterceptors(registry);
    }
}
